In [30]:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
In [31]:
width = 3.18 # cm
thickness = 0.46 # cm
length = 48 # cm
volume = length*width*thickness # cm^3
density = 2.77 # g/cm
massBar = density*volume
print('mass of bar =', massBar, 'g')
gammaL = 1.88 # from lab procedures (for first harmonic)
In [32]:
dirPath = os.path.realpath('.')
fileName = 'rawData/lab7data.xlsx'
filePath = os.path.join(dirPath, fileName)
df = pd.read_excel(filePath,sheetname="Part2",header=0)
print(df)
cols = df.columns
Now lets get to the math.
Dynamic loading is described by the following equation.
$$ \omega_n = (\lambda L)^2 \sqrt{\frac{k}{3(M + 4.167m)}} $$Rearranging to solve for k..
$$ k = \frac{\omega_n}{(\lambda L)^4}*(3(M+4.167m)) $$
In [44]:
angularFreq = 2*np.pi*df['Frequency (Hz)']
k = angularFreq**2/(gammaL)**4 * 3*(massBar/1000+4.167*df['Weight']/1000)
print('k average =', np.average(k), 'N/m')
print('k max =', np.max(k), 'N/m')
print('k min =', np.min(k), 'N/m')
print('k std =', np.std(k), 'N/m')
In [43]:
plt.figure(1)
plt.errorbar(df['Weight'], df['Frequency (Hz)'], yerr=2*df['error'], fmt='o')
plt.xlabel('Weight (g)')
plt.ylabel('Frequency (Hz)')
plt.title('Part 2: Dynamic Loading')
plt.grid()
plt.show()
In [ ]: